import data
import time
from src.data import DataSeq
def CombSort(ds,v):
    Length = ds.length
    D = int(Length / 1.3)

    while D:
        for i in range(Length):
            for j in range(i + D, Length, D):
                if ds.data[j - D] > ds.data[j]:
                    ds.Swap(j - D, j)
        D = int(D / 1.3)
        time.sleep(v)


def create_sort(title, v, l):
    ds = DataSeq(l, sort_title=title)
    ds.Visualize()
    ds.StartTimer()
    CombSort(ds,v)
    ds.StopTimer()
    ds.SetTimeInterval(0)
    # ds.Visualize()
    time.sleep(3)
    ds.destory()
    return 0


if __name__ == "__main__":
    # ds = DataSeq(64, repeatition=True)
    ds = data.DataSeq(64)
    ds.Visualize()
    ds.StartTimer()
    CombSort(ds)
    ds.StopTimer()
    ds.SetTimeInterval(0)
    # 负责最后显不显示内容
    # ds.Visualize()
